package com.gitee.flow;

import com.gitee.flow.service.FlowRead;
import com.gitee.flow.service.FlowWrite;
import com.gitee.flow.service.HiTaskinstRead;
import com.gitee.flow.service.HiTaskinstWrite;
import jakarta.enterprise.inject.spi.CDI;

/**
 * 模块服务工厂类.
 *
 * @author CGD
 *
 */
public class FlowFactory {

  public static FlowRead getFlowRead(String tenant) {
    return CDI.current().select(FlowRead.class).get().setTenant(tenant);
  }

  public static HiTaskinstRead getHiTaskinstRead(String tenant) {
    return CDI.current().select(HiTaskinstRead.class).get().setTenant(tenant);
  }

  public static FlowWrite getFlowWrite(String tenant) {
    return CDI.current().select(FlowWrite.class).get().setTenant(tenant);
  }

  public static HiTaskinstWrite getHiTaskinstWrite(String tenant) {
    return CDI.current().select(HiTaskinstWrite.class).get().setTenant(tenant);
  }

  /** CDI回收实例. */
  public static void destroy(Object instance) {
    if (null != instance) {
      CDI.current().destroy(instance);
    }
  }
}
